/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import Base.PersonaDB;
import Negocio.Conexion;
import Negocio.Encuesta;
import Negocio.Persona;
import java.awt.Component;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
 *
 * @author Alina
 */
public class InterfazAdmin extends javax.swing.JFrame {

    
    /**
     * Creates new form Administrador
     */public String cedulaActual;
     public String cabAnt,titAnt,despAnt;
     ArrayList <Encuesta> listaEncuestas= new ArrayList<Encuesta>();
     public Conexion log = new Conexion();
    public InterfazAdmin() throws SQLException {
        initComponents();
        this.setLocationRelativeTo(null);
        this.cargarCombos();
        this.deshabilitarTipoUsuario();
        
        
    }

    
    ArrayList<String> telefonos = new ArrayList();
    ArrayList<String> correos = new ArrayList();
    int banderaE=0;
    DefaultTableModel auxReporteFacultad=new DefaultTableModel();
    DefaultTableModel auxReporteEscuela=new DefaultTableModel();
    DefaultTableModel auxReporteMetodo=new DefaultTableModel();
    DefaultTableModel auxReporteEstado=new DefaultTableModel();
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dlgmodificar = new javax.swing.JDialog();
        jLabel16 = new javax.swing.JLabel();
        cmdmodificarDescripcion = new javax.swing.JButton();
        cmdcancelar = new javax.swing.JButton();
        jLabel29 = new javax.swing.JLabel();
        txtTitulo = new javax.swing.JTextField();
        jScrollPane8 = new javax.swing.JScrollPane();
        txtCabecera = new javax.swing.JTextPane();
        jLabel28 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        txtDespedida = new javax.swing.JTextPane();
        dlgciudad = new javax.swing.JDialog();
        jLabel26 = new javax.swing.JLabel();
        txtnuevaCiudad = new javax.swing.JTextField();
        cmdmodificarDescripcion1 = new javax.swing.JButton();
        cmdcancelar1 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtcedula = new javax.swing.JTextField();
        txtnombres = new javax.swing.JTextField();
        txtapellidos = new javax.swing.JTextField();
        txtcorreo = new javax.swing.JTextField();
        txttelefono = new javax.swing.JTextField();
        cmdBuscar = new javax.swing.JButton();
        cmdCrear = new javax.swing.JButton();
        cmdModificar = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        txtclave = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtdireccion = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablaTelefonos = new javax.swing.JTable();
        cmdAgregarC = new javax.swing.JButton();
        cmdAgregarT = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tablaCorreos = new javax.swing.JTable();
        cmdeliminarC = new javax.swing.JButton();
        cmdeliminarT = new javax.swing.JButton();
        cmdNuevo = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        cmbTipoUsuario = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        tablaElegirFacultad = new javax.swing.JTable();
        cmbTipoFacultad = new javax.swing.JComboBox();
        cmbTipoEscuela = new javax.swing.JComboBox();
        cmdAgregarFacultad = new javax.swing.JButton();
        cmdQuitarFacultad = new javax.swing.JButton();
        jLabel22 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtCorreoPrincipal = new javax.swing.JTextField();
        cmdTelefonoPrincipal = new javax.swing.JButton();
        cmdCorreoPrincipal = new javax.swing.JButton();
        jLabel23 = new javax.swing.JLabel();
        txtTelefonoPrincipal = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        cmbMetodoContacto = new javax.swing.JComboBox();
        txtMetodoC = new javax.swing.JTextField();
        cmbciudad = new javax.swing.JComboBox();
        cmdAgregarCiudad = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        cmbExContactado = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaConsulta = new javax.swing.JTable();
        cmdActualizar = new javax.swing.JButton();
        txtcampo = new javax.swing.JTextField();
        cmbbuscar = new javax.swing.JComboBox();
        cmbfacultades = new javax.swing.JComboBox();
        cmbescuelas = new javax.swing.JComboBox();
        cmbmetodo = new javax.swing.JComboBox();
        cmbcontactado = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        chkfacultad = new javax.swing.JCheckBox();
        jLabel10 = new javax.swing.JLabel();
        chkescuela = new javax.swing.JCheckBox();
        chkcedula = new javax.swing.JCheckBox();
        chknombres = new javax.swing.JCheckBox();
        chkapellidos = new javax.swing.JCheckBox();
        chkmetodo = new javax.swing.JCheckBox();
        chkcontacto = new javax.swing.JCheckBox();
        chkcontactado = new javax.swing.JCheckBox();
        cmdverInfo = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaPorFacultad = new javax.swing.JTable();
        cmdreporteF = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tablaPorEscuela = new javax.swing.JTable();
        cmdreporteE = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        cmbfacultad = new javax.swing.JComboBox();
        cmbescuela = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        txtcedula1 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        cmdasignarC = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        cmdasignarF = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tablaEncuesta = new javax.swing.JTable();
        cmddesasignarC = new javax.swing.JButton();
        cmddesasignarF = new javax.swing.JButton();
        cmdcrearE = new javax.swing.JButton();
        cmdmodificarE = new javax.swing.JButton();
        cmdeliminarE = new javax.swing.JButton();
        cmddeshabilitar = new javax.swing.JButton();
        cmdhabilitar = new javax.swing.JButton();
        lblusuario = new javax.swing.JLabel();
        cmdsalir = new javax.swing.JButton();

        jLabel16.setText("Ingrese la cabecera para la encuesta:");

        cmdmodificarDescripcion.setText("Aceptar");
        cmdmodificarDescripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdmodificarDescripcionActionPerformed(evt);
            }
        });

        cmdcancelar.setText("Cancelar");
        cmdcancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdcancelarActionPerformed(evt);
            }
        });

        jLabel29.setText("Ingrese el titulo para la encuesta:");

        txtTitulo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTituloActionPerformed(evt);
            }
        });

        jScrollPane8.setViewportView(txtCabecera);

        jLabel28.setText("Ingrese la despedida para la encuesta:");

        jScrollPane9.setViewportView(txtDespedida);

        javax.swing.GroupLayout dlgmodificarLayout = new javax.swing.GroupLayout(dlgmodificar.getContentPane());
        dlgmodificar.getContentPane().setLayout(dlgmodificarLayout);
        dlgmodificarLayout.setHorizontalGroup(
            dlgmodificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dlgmodificarLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(cmdmodificarDescripcion)
                .addGap(116, 116, 116)
                .addComponent(cmdcancelar)
                .addGap(144, 144, 144))
            .addGroup(dlgmodificarLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(dlgmodificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 486, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel29)
                    .addComponent(jLabel16)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 486, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel28))
                .addContainerGap(46, Short.MAX_VALUE))
        );
        dlgmodificarLayout.setVerticalGroup(
            dlgmodificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgmodificarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel29)
                .addGap(18, 18, 18)
                .addComponent(txtTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel28)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addGroup(dlgmodificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdcancelar)
                    .addComponent(cmdmodificarDescripcion))
                .addContainerGap())
        );

        jLabel26.setText("Ingrese la descripcion para la encuesta:");

        txtnuevaCiudad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtnuevaCiudadActionPerformed(evt);
            }
        });

        cmdmodificarDescripcion1.setText("Aceptar");
        cmdmodificarDescripcion1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdmodificarDescripcion1ActionPerformed(evt);
            }
        });

        cmdcancelar1.setText("Cancelar");
        cmdcancelar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdcancelar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dlgciudadLayout = new javax.swing.GroupLayout(dlgciudad.getContentPane());
        dlgciudad.getContentPane().setLayout(dlgciudadLayout);
        dlgciudadLayout.setHorizontalGroup(
            dlgciudadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgciudadLayout.createSequentialGroup()
                .addGroup(dlgciudadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dlgciudadLayout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(dlgciudadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel26)
                            .addComponent(txtnuevaCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(dlgciudadLayout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addComponent(cmdmodificarDescripcion1)
                        .addGap(44, 44, 44)
                        .addComponent(cmdcancelar1)))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        dlgciudadLayout.setVerticalGroup(
            dlgciudadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgciudadLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel26)
                .addGap(18, 18, 18)
                .addComponent(txtnuevaCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19)
                .addGroup(dlgciudadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdmodificarDescripcion1)
                    .addComponent(cmdcancelar1))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("Cedula/Nombre de Usuario: ");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 88, -1, -1));

        jLabel2.setText("Nombres:");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 167, -1, -1));

        jLabel3.setText("Apellidos:");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 205, -1, -1));

        jLabel4.setText("Correo electronico:");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 80, -1, -1));

        jLabel5.setText("Telefono:");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 300, -1, -1));

        txtcedula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtcedulaActionPerformed(evt);
            }
        });
        jPanel1.add(txtcedula, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 90, 140, -1));

        txtnombres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtnombresActionPerformed(evt);
            }
        });
        jPanel1.add(txtnombres, new org.netbeans.lib.awtextra.AbsoluteConstraints(102, 164, 368, -1));

        txtapellidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtapellidosActionPerformed(evt);
            }
        });
        jPanel1.add(txtapellidos, new org.netbeans.lib.awtextra.AbsoluteConstraints(102, 202, 368, -1));

        txtcorreo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtcorreoActionPerformed(evt);
            }
        });
        jPanel1.add(txtcorreo, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 80, 259, -1));

        txttelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txttelefonoActionPerformed(evt);
            }
        });
        jPanel1.add(txttelefono, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 300, 259, -1));

        cmdBuscar.setText("Buscar...");
        cmdBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdBuscarActionPerformed(evt);
            }
        });
        jPanel1.add(cmdBuscar, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 90, -1, -1));

        cmdCrear.setText("Guardar...");
        cmdCrear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdCrearActionPerformed(evt);
            }
        });
        jPanel1.add(cmdCrear, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 580, 90, 41));

        cmdModificar.setText("Modificar...");
        cmdModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdModificarActionPerformed(evt);
            }
        });
        jPanel1.add(cmdModificar, new org.netbeans.lib.awtextra.AbsoluteConstraints(910, 580, -1, 43));

        jLabel7.setText("Contraseña:");
        jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 129, -1, -1));

        txtclave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtclaveActionPerformed(evt);
            }
        });
        jPanel1.add(txtclave, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 130, 140, -1));

        jLabel6.setText("Direccion:");
        jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 251, -1, -1));

        txtdireccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtdireccionActionPerformed(evt);
            }
        });
        jPanel1.add(txtdireccion, new org.netbeans.lib.awtextra.AbsoluteConstraints(102, 248, 368, -1));

        tablaTelefonos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Numero"
            }
        ));
        jScrollPane3.setViewportView(tablaTelefonos);

        jPanel1.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 350, 255, 82));

        cmdAgregarC.setText("Agregar...");
        cmdAgregarC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAgregarCActionPerformed(evt);
            }
        });
        jPanel1.add(cmdAgregarC, new org.netbeans.lib.awtextra.AbsoluteConstraints(1010, 80, -1, -1));

        cmdAgregarT.setText("Agregar...");
        cmdAgregarT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAgregarTActionPerformed(evt);
            }
        });
        jPanel1.add(cmdAgregarT, new org.netbeans.lib.awtextra.AbsoluteConstraints(990, 300, -1, -1));

        tablaCorreos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Correo electronico"
            }
        ));
        jScrollPane4.setViewportView(tablaCorreos);

        jPanel1.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 140, 259, 82));

        cmdeliminarC.setText("Eliminar correo...");
        cmdeliminarC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdeliminarCActionPerformed(evt);
            }
        });
        jPanel1.add(cmdeliminarC, new org.netbeans.lib.awtextra.AbsoluteConstraints(990, 190, 160, -1));

        cmdeliminarT.setText("Eliminar telefono...");
        cmdeliminarT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdeliminarTActionPerformed(evt);
            }
        });
        jPanel1.add(cmdeliminarT, new org.netbeans.lib.awtextra.AbsoluteConstraints(990, 400, -1, -1));

        cmdNuevo.setText("Nuevo...");
        cmdNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdNuevoActionPerformed(evt);
            }
        });
        jPanel1.add(cmdNuevo, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 580, -1, 41));

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel18.setText("Informacion de Contacto");
        jPanel1.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 30, 171, -1));

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel19.setText("Tipo de usuario");
        jPanel1.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 340, 171, 32));

        cmbTipoUsuario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguno", "Administrador general", "Administrador por facultad", "Ayudante", "Exalumno" }));
        cmbTipoUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbTipoUsuarioActionPerformed(evt);
            }
        });
        jPanel1.add(cmbTipoUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 380, 163, -1));

        jLabel20.setText("Elija el tipo de usuario:");
        jPanel1.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 380, 140, -1));

        jLabel21.setText("Elija la facultad:");
        jPanel1.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, 140, -1));

        tablaElegirFacultad.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Facultad", "Escuela"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane7.setViewportView(tablaElegirFacultad);

        jPanel1.add(jScrollPane7, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 490, 400, 133));

        cmbTipoFacultad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Facultad" }));
        cmbTipoFacultad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbTipoFacultadActionPerformed(evt);
            }
        });
        jPanel1.add(cmbTipoFacultad, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 410, 163, -1));

        cmbTipoEscuela.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Escuela" }));
        cmbTipoEscuela.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbTipoEscuelaActionPerformed(evt);
            }
        });
        jPanel1.add(cmbTipoEscuela, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 440, 163, -1));

        cmdAgregarFacultad.setText("Agregar");
        cmdAgregarFacultad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAgregarFacultadActionPerformed(evt);
            }
        });
        jPanel1.add(cmdAgregarFacultad, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 410, 91, -1));

        cmdQuitarFacultad.setText("Quitar");
        cmdQuitarFacultad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdQuitarFacultadActionPerformed(evt);
            }
        });
        jPanel1.add(cmdQuitarFacultad, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 630, 91, -1));

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel22.setText("Informacion de Personal");
        jPanel1.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 30, 171, -1));

        jLabel17.setText("Correo principal:");
        jPanel1.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 240, 100, -1));
        jPanel1.add(txtCorreoPrincipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 240, 260, -1));

        cmdTelefonoPrincipal.setText("Elegir como principal...");
        cmdTelefonoPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdTelefonoPrincipalActionPerformed(evt);
            }
        });
        jPanel1.add(cmdTelefonoPrincipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(990, 360, 160, -1));

        cmdCorreoPrincipal.setText("Elegir como principal...");
        cmdCorreoPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdCorreoPrincipalActionPerformed(evt);
            }
        });
        jPanel1.add(cmdCorreoPrincipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(990, 150, 160, -1));

        jLabel23.setText("Telefono principal:");
        jPanel1.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 450, 150, -1));
        jPanel1.add(txtTelefonoPrincipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 450, 260, -1));

        jLabel24.setText("Ciudad:");
        jPanel1.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 292, -1, -1));

        jLabel25.setText("Elegir metodo de contcto:");
        jPanel1.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 505, 170, -1));

        cmbMetodoContacto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Elija una opcion...", "Telefono", "Correo electronico", "Otro" }));
        cmbMetodoContacto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbMetodoContactoActionPerformed(evt);
            }
        });
        jPanel1.add(cmbMetodoContacto, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 502, 170, -1));

        txtMetodoC.setEditable(false);
        jPanel1.add(txtMetodoC, new org.netbeans.lib.awtextra.AbsoluteConstraints(997, 502, 153, -1));

        cmbciudad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Elija una ciudad..." }));
        jPanel1.add(cmbciudad, new org.netbeans.lib.awtextra.AbsoluteConstraints(102, 289, 178, -1));

        cmdAgregarCiudad.setText("Agregar ciudad");
        cmdAgregarCiudad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAgregarCiudadActionPerformed(evt);
            }
        });
        jPanel1.add(cmdAgregarCiudad, new org.netbeans.lib.awtextra.AbsoluteConstraints(318, 288, 152, -1));

        jLabel27.setText("Se ha contactado:");
        jPanel1.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 536, 170, -1));

        cmbExContactado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Elija una opcion...", "SI", "NO" }));
        cmbExContactado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbExContactadoActionPerformed(evt);
            }
        });
        jPanel1.add(cmbExContactado, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 533, 170, -1));

        jTabbedPane1.addTab("Usuarios", jPanel1);

        tablaConsulta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "FACULTAD", "ESCUELA", "CEDULA", "NOMBRES", "APELLIDOS", "METODO_CONTACTO", "CONTACTO", "CONTACTADO"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tablaConsulta);

        cmdActualizar.setText("Actualizar");
        cmdActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdActualizarActionPerformed(evt);
            }
        });

        cmbbuscar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Elegir campos...", "Todos los campos", "Cedula", "Nombre", "Apellido" }));
        cmbbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbbuscarActionPerformed(evt);
            }
        });

        cmbfacultades.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Facultad" }));
        cmbfacultades.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cmbfacultadesMouseClicked(evt);
            }
        });
        cmbfacultades.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbfacultadesActionPerformed(evt);
            }
        });

        cmbescuelas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Escuela" }));
        cmbescuelas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cmbescuelasMouseClicked(evt);
            }
        });
        cmbescuelas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbescuelasActionPerformed(evt);
            }
        });

        cmbmetodo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Metodo de Contacto", "Correo", "Telefono", "Otro" }));
        cmbmetodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbmetodoActionPerformed(evt);
            }
        });

        cmbcontactado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Estado", "Contactado", "No contactado" }));
        cmbcontactado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbcontactadoActionPerformed(evt);
            }
        });

        jLabel9.setText("Buscar por...");

        chkfacultad.setText("Facultad");

        jLabel10.setText("Ordenar por...");

        chkescuela.setText("Escuela");

        chkcedula.setText("Cedula");

        chknombres.setText("Nombres");

        chkapellidos.setText("Apellidos");

        chkmetodo.setText("Metodo de contacto");

        chkcontacto.setText("Contacto");

        chkcontactado.setText("Contactado");

        cmdverInfo.setText("Ver informacion del estudiante seleccionado");
        cmdverInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdverInfoActionPerformed(evt);
            }
        });

        jButton1.setText("Filtrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1217, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(31, 31, 31)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtcampo, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(37, 37, 37)
                                        .addComponent(cmbbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(71, 71, 71)
                                        .addComponent(cmdActualizar))
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(chkfacultad)
                                                .addGap(18, 18, 18)
                                                .addComponent(chkescuela))
                                            .addComponent(chkmetodo))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(chkcontacto)
                                            .addComponent(chkcedula))
                                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addComponent(chknombres)
                                                .addGap(18, 18, 18)
                                                .addComponent(chkapellidos))
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addGap(30, 30, 30)
                                                .addComponent(chkcontactado))))
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(cmbfacultades, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(cmbescuelas, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(45, 45, 45)
                                        .addComponent(cmbmetodo, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(39, 39, 39)
                                        .addComponent(cmbcontactado, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(69, 69, 69)
                                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(40, 40, 40)
                                .addComponent(cmdverInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 340, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtcampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkfacultad)
                    .addComponent(jLabel10)
                    .addComponent(chkescuela)
                    .addComponent(chkcedula)
                    .addComponent(chknombres)
                    .addComponent(chkapellidos))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkmetodo)
                    .addComponent(chkcontacto)
                    .addComponent(chkcontactado))
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbfacultades, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbescuelas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbmetodo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbcontactado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 415, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cmdverInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Reporte alumnos", jPanel3);

        tablaPorFacultad.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "FACULTAD", "Num. ESTUDIANTES", "% ESTUDIANTES CONTACTADOS", "% ENCUESTA1"
            }
        ));
        jScrollPane2.setViewportView(tablaPorFacultad);

        cmdreporteF.setText("Actualizar");
        cmdreporteF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdreporteFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(128, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmdreporteF, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 1002, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(107, 107, 107))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(cmdreporteF)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 536, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(56, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Reporte por Facultad", jPanel4);

        tablaPorEscuela.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "FACULTAD", "ESCUELA", "Num. ESTUDIANTES", "% ESTUDIANTES CONTACTADOS", "% ENCUESTA1"
            }
        ));
        jScrollPane5.setViewportView(tablaPorEscuela);

        cmdreporteE.setText("Actualizar");
        cmdreporteE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdreporteEActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 1138, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmdreporteE, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(60, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(cmdreporteE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 545, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(65, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Reporte por Escuela", jPanel5);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setText("Asignacion de encuenstas para los alumnos de la Univesidad de Cuenca");

        cmbfacultad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione una facultad..." }));
        cmbfacultad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbfacultadActionPerformed(evt);
            }
        });

        cmbescuela.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione una una escuela...", "Todas" }));
        cmbescuela.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbescuelaActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel11.setText("Metodo de asignacion:");

        txtcedula1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtcedula1ActionPerformed(evt);
            }
        });
        txtcedula1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtcedula1KeyPressed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel12.setText("Individual por exalumo:");

        jLabel13.setText("Cedula:");

        cmdasignarC.setText("Conceder acceso...");
        cmdasignarC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdasignarCActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel14.setText("Por facultad y escuela:");

        cmdasignarF.setText("Conceder acceso...");
        cmdasignarF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdasignarFActionPerformed(evt);
            }
        });

        jLabel15.setText("Seleccione una encuesta:");

        tablaEncuesta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "IDENTIFICADOR", "DESCRIPCION", "ESTADO"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane6.setViewportView(tablaEncuesta);

        cmddesasignarC.setText("Denegar acceso...");
        cmddesasignarC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmddesasignarCActionPerformed(evt);
            }
        });

        cmddesasignarF.setText("Denegar acceso...");
        cmddesasignarF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmddesasignarFActionPerformed(evt);
            }
        });

        cmdcrearE.setText("Crear");
        cmdcrearE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdcrearEActionPerformed(evt);
            }
        });

        cmdmodificarE.setText("Modificar Encuesta");
        cmdmodificarE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdmodificarEActionPerformed(evt);
            }
        });

        cmdeliminarE.setText("Eliminar");
        cmdeliminarE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdeliminarEActionPerformed(evt);
            }
        });

        cmddeshabilitar.setText("Deshabilitar");
        cmddeshabilitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmddeshabilitarActionPerformed(evt);
            }
        });

        cmdhabilitar.setText("Habilitar");
        cmdhabilitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdhabilitarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 493, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel14)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(162, 162, 162)
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(cmbescuela, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(cmbfacultad, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(jLabel13)
                                                .addGap(18, 18, 18)
                                                .addComponent(txtcedula1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addGap(77, 77, 77)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmdasignarF)
                                    .addComponent(cmdasignarC))
                                .addGap(32, 32, 32)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmddesasignarF)
                                    .addComponent(cmddesasignarC)))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(191, 191, 191)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 646, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(48, 48, 48)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(cmdmodificarE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cmdcrearE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cmdeliminarE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cmdhabilitar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cmddeshabilitar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(229, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel8)
                .addGap(32, 32, 32)
                .addComponent(jLabel15)
                .addGap(35, 35, 35)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmdcrearE)
                        .addGap(18, 18, 18)
                        .addComponent(cmdmodificarE)
                        .addGap(18, 18, 18)
                        .addComponent(cmdeliminarE)
                        .addGap(18, 18, 18)
                        .addComponent(cmdhabilitar)
                        .addGap(18, 18, 18)
                        .addComponent(cmddeshabilitar))
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addComponent(jLabel11)
                .addGap(18, 18, 18)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtcedula1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(cmdasignarC))
                        .addGap(23, 23, 23)
                        .addComponent(jLabel14)
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbfacultad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmdasignarF))
                        .addGap(25, 25, 25)
                        .addComponent(cmbescuela, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmddesasignarC)
                        .addGap(48, 48, 48)
                        .addComponent(cmddesasignarF)))
                .addGap(115, 115, 115))
        );

        jTabbedPane1.addTab("Encuestas", jPanel2);

        getContentPane().add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, 685));

        lblusuario.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblusuario.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lblusuario.setText("jLabel16");
        getContentPane().add(lblusuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(891, 12, 235, -1));

        cmdsalir.setText("Cerrar cesion");
        cmdsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdsalirActionPerformed(evt);
            }
        });
        getContentPane().add(cmdsalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(1136, 11, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cmdActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdActualizarActionPerformed
        Conexion conexion = new Conexion();
        String campo=this.txtcampo.getText().toUpperCase();
        
        String orden=verificarOrden();
        
        DefaultTableModel temp = (DefaultTableModel) tablaConsulta.getModel();
        for (int i = tablaConsulta.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        tablaConsulta.setModel(temp);
        try {
            if (String.valueOf(this.cmbbuscar.getSelectedItem()).equals("Todos los campos") && String.valueOf(this.cmbfacultades.getSelectedItem()).equals("Facultad") && String.valueOf(this.cmbescuelas.getSelectedItem()).equals("Escuela") && String.valueOf(this.cmbmetodo.getSelectedItem()).equals("Metodo de Contacto") && String.valueOf(this.cmbcontactado.getSelectedItem()).equals("Estado")) {

                temp = (DefaultTableModel) tablaConsulta.getModel();
                tablaConsulta.setModel(conexion.reporteAlumnos(temp,orden));
            }
            if (String.valueOf(this.cmbbuscar.getSelectedItem()).equals("Cedula") && String.valueOf(this.cmbfacultades.getSelectedItem()).equals("Facultad") && String.valueOf(this.cmbescuelas.getSelectedItem()).equals("Escuela") && String.valueOf(this.cmbmetodo.getSelectedItem()).equals("Metodo de Contacto") && String.valueOf(this.cmbcontactado.getSelectedItem()).equals("Estado")) {
                temp = (DefaultTableModel) tablaConsulta.getModel();
                tablaConsulta.setModel(conexion.reportePorCedula(temp, campo,orden));
            }
            
            if (String.valueOf(this.cmbbuscar.getSelectedItem()).equals("Nombre") && String.valueOf(this.cmbfacultades.getSelectedItem()).equals("Facultad") && String.valueOf(this.cmbescuelas.getSelectedItem()).equals("Escuela") && String.valueOf(this.cmbmetodo.getSelectedItem()).equals("Metodo de Contacto") && String.valueOf(this.cmbcontactado.getSelectedItem()).equals("Estado")) {
                temp = (DefaultTableModel) tablaConsulta.getModel();
                tablaConsulta.setModel(conexion.reportePorNombre(temp, campo,orden));
            }
            if (String.valueOf(this.cmbbuscar.getSelectedItem()).equals("Apellido") && String.valueOf(this.cmbfacultades.getSelectedItem()).equals("Facultad") && String.valueOf(this.cmbescuelas.getSelectedItem()).equals("Escuela") && String.valueOf(this.cmbmetodo.getSelectedItem()).equals("Metodo de Contacto") && String.valueOf(this.cmbcontactado.getSelectedItem()).equals("Estado")) {
                temp = (DefaultTableModel) tablaConsulta.getModel();
                tablaConsulta.setModel(conexion.reportePorApellido(temp, campo,orden));
            }
              
            auxReporteFacultad=(DefaultTableModel) tablaConsulta.getModel();
            auxReporteEscuela=(DefaultTableModel) tablaConsulta.getModel();
            auxReporteMetodo=(DefaultTableModel) tablaConsulta.getModel();
            auxReporteEstado=(DefaultTableModel) tablaConsulta.getModel();
            
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.txtcampo.setText(null);
        cmbmetodo.setEnabled(true);
        cmbescuelas.setEnabled(true);
        cmbcontactado.setEnabled(true);
        cmbfacultades.setEnabled(true);
        this.cmbbuscar.setSelectedItem("Elegir campos...");
        deshabilitarOrden();
        
    }//GEN-LAST:event_cmdActualizarActionPerformed

    private void cmdeliminarTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdeliminarTActionPerformed
        String tel = String.valueOf(tablaTelefonos.getValueAt(tablaTelefonos.getSelectedRow(), 0));

        telefonos.remove(tel);

        DefaultTableModel temp = (DefaultTableModel) tablaTelefonos.getModel();
        for (int i = tablaTelefonos.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < telefonos.size(); i++) {

            Object nuevo[] = {telefonos.get(i)}; //esto es por las tres columnas aunque puede variar

            temp.addRow(nuevo);
        }
        tablaTelefonos.setModel(temp);
    }//GEN-LAST:event_cmdeliminarTActionPerformed

    private void cmdeliminarCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdeliminarCActionPerformed
        String correo = String.valueOf(tablaCorreos.getValueAt(tablaCorreos.getSelectedRow(), 0));
        correos.remove(correo);
        DefaultTableModel temp = (DefaultTableModel) tablaCorreos.getModel();
        for (int i = tablaCorreos.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < correos.size(); i++) {

            Object nuevo[] = {correos.get(i)}; //esto es por las tres columnas aunque puede variar

            temp.addRow(nuevo);
        }
        tablaCorreos.setModel(temp);




    }//GEN-LAST:event_cmdeliminarCActionPerformed

    private void cmdAgregarTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAgregarTActionPerformed
        DefaultTableModel temp = (DefaultTableModel) tablaTelefonos.getModel();
        Object nuevo[] = {this.txttelefono.getText()}; //esto es por las tres columnas aunque puede variar
        temp.addRow(nuevo);
        tablaTelefonos.setModel(temp);
        this.telefonos.add(this.txttelefono.getText());
        this.txttelefono.setText(null);
    }//GEN-LAST:event_cmdAgregarTActionPerformed

    private void cmdAgregarCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAgregarCActionPerformed
        DefaultTableModel temp = (DefaultTableModel) tablaCorreos.getModel();
        Object nuevo[] = {this.txtcorreo.getText()}; //esto es por las tres columnas aunque puede variar
        temp.addRow(nuevo);
        tablaCorreos.setModel(temp);
        this.correos.add(this.txtcorreo.getText());
        this.txtcorreo.setText(null);

    }//GEN-LAST:event_cmdAgregarCActionPerformed

    private void txtdireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtdireccionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtdireccionActionPerformed

    private void txtclaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtclaveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtclaveActionPerformed

    private void cmdModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdModificarActionPerformed
        
        
        Conexion conexion = new Conexion();
        try {

            int b = conexion.modificarPersona(this.txtcedula.getText(), this.txtnombres.getText(), this.txtapellidos.getText(), this.txtdireccion.getText());
            
            conexion.modificarClave(this.txtcedula.getText(),this.txtclave.getText());
            conexion.modificarCiudad(this.txtcedula.getText(),(String)this.cmbciudad.getSelectedItem());
            String contacto=(String) this.cmbExContactado.getSelectedItem();
            int c=0;
            if(contacto.equalsIgnoreCase("SI"))
            {c=1;}
                
            conexion.modificarMetodo(this.cmbMetodoContacto.getSelectedIndex(),c,this.txtcedula.getText());
            
            if (this.cmbMetodoContacto.getSelectedIndex()==3)
            {
                conexion.grabarPersonaOtro(this.txtcedula.getText(),this.txtMetodoC.getText());
            }
            
            
            conexion.eliminarTelefonoPersona(this.txtcedula.getText());
            for (int i = 0; i < telefonos.size(); i++) {
                if (!conexion.buscarTelefono(telefonos.get(i))) {
                    conexion.grabarTelefono(telefonos.get(i));
                }

                if (telefonos.get(i).equals(txtTelefonoPrincipal.getText())){
                    System.out.println("principal");
                    conexion.PersonaTelefono(this.txtcedula.getText(),telefonos.get(i),1); 
                } else {
                    conexion.PersonaTelefono(this.txtcedula.getText(),telefonos.get(i),0); 
                }
            }


            conexion.eliminarCorreoPersona(this.txtcedula.getText());
            for (int i = 0; i < correos.size(); i++) {
                if (!conexion.buscarCorreo(correos.get(i))) {
                    
                    conexion.grabarCorreo(correos.get(i));
                }
                if (correos.get(i).equals(txtCorreoPrincipal.getText())){
                    conexion.PersonaCorreo(this.txtcedula.getText(),correos.get(i),1); 
                } else {
                    conexion.PersonaCorreo(this.txtcedula.getText(),correos.get(i),0); 
                }
            }

            if (b == 1) {
                JOptionPane.showMessageDialog(this, "Datos modificados");
                log.ingersarLog(this.cedulaActual, "MODIFICADO USUARIO: "+this.txtcedula.getText());

            }

        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        //vaciarCampos();
        this.cmbTipoFacultad.removeAllItems();
        this.cmbTipoFacultad.addItem("Facultad");
        this.cmbTipoEscuela.removeAllItems();
        this.cmbTipoEscuela.addItem("Escuela");
        
        this.cmdNuevo.setEnabled(true);
                this.cmdCrear.setEnabled(false);
        
    }//GEN-LAST:event_cmdModificarActionPerformed

    private void cmdCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCrearActionPerformed
        if(this.comprobarCampos()==0)
        {
        Persona alumno = new Persona();
        alumno.setCedula(txtcedula.getText());
        alumno.setNombres(txtnombres.getText());
        alumno.setApellidos(txtapellidos.getText());
        alumno.setDireccion(txtdireccion.getText());
        Conexion conexion = new Conexion();


        try {
            conexion.grabarPersona(alumno);
            
            if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Administrador General"))
            {
               conexion.grabarAdministrador(alumno.getCedula());
               log.ingersarLog(alumno.getCedula(), "ADMINSTRADOR CREADO: "+alumno.getCedula());
            }
            if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Administrador por Facultad"))
            {
               conexion.grabarAdministrador(alumno.getCedula()); 
               
               for (int i=0;i<tablaElegirFacultad.getRowCount();i++)
               {
                String fac=conexion.buscarFacultad(String.valueOf(tablaElegirFacultad.getValueAt(i, 0)));
                conexion.grabarAdministradorFacultad(alumno.getCedula(),fac);
                log.ingersarLog(alumno.getCedula(), "ADMINSTRADOR DE"+fac+" CREADO: "+alumno.getCedula());
               }
               
            }
            if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Ayudante"))
            {
               conexion.grabarAyudante(alumno.getCedula()); 
               log.ingersarLog(alumno.getCedula(), "AYUDANTE CREADO: "+alumno.getCedula());
            }
            if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Exalumno"))
            {
                conexion.grabarExalumno(alumno.getCedula());
               for (int i=0;i<tablaElegirFacultad.getRowCount();i++)
               {
                
                String esc=conexion.buscarEscuela(String.valueOf(tablaElegirFacultad.getValueAt(i, 1)));
                String titulo=conexion.buscarTitulo(esc);
                
                conexion.grabarExalumnoTitulo(alumno.getCedula(),titulo);            
                log.ingersarLog(alumno.getCedula(), "EXALUMNO CREADO: "+alumno.getCedula());
                 
               }
            }
            conexion.grabarUsuario(txtcedula.getText(), txtcedula.getText());
            conexion.grabarCiudadPersona(txtcedula.getText(),(String)cmbciudad.getSelectedItem());
            String contacto=(String) this.cmbExContactado.getSelectedItem();
            int c=0;
            if(contacto.equalsIgnoreCase("SI"))
            {c=1;}
                
            conexion.grabarMetodo(this.cmbMetodoContacto.getSelectedIndex(),c,this.txtcedula.getText());
            if (this.cmbMetodoContacto.getSelectedIndex()==3)
            {
                conexion.grabarPersonaOtro(this.txtcedula.getText(),this.txtMetodoC.getText());
            }

            for (int i = 0; i < correos.size(); i++) {
                if (!conexion.buscarCorreo(correos.get(i))) {
                    conexion.grabarCorreo(correos.get(i));
                }
                if (correos.get(i).equals(txtCorreoPrincipal.getText())){
                    conexion.PersonaCorreo(this.txtcedula.getText(),correos.get(i),1); 
                } else {
                    conexion.PersonaCorreo(this.txtcedula.getText(),correos.get(i),0); 
                }
            }
            for (int i = 0; i < telefonos.size(); i++) {
                if (!conexion.buscarTelefono(telefonos.get(i))) {
                    conexion.grabarTelefono(telefonos.get(i));
                }
                if (telefonos.get(i).equals(txtTelefonoPrincipal.getText())){
                
                    conexion.PersonaTelefono(this.txtcedula.getText(),telefonos.get(i),1); 
                } else {
                    conexion.PersonaTelefono(this.txtcedula.getText(),telefonos.get(i),0); 
                }
            }
            
            
            deshabilitarTipoUsuario();
            JOptionPane.showMessageDialog(this, "Datos Grabados Satisfactoriamente...");
            this.cmdNuevo.setEnabled(true);
                this.cmdModificar.setEnabled(true);
                this.cmdCrear.setEnabled(false);

            //lblMensaje.setVisible(true);
        } catch (SQLException ex) {

            JOptionPane.showMessageDialog(this, "Error de conexion con la Base de Datos...");

        }
        }
    }//GEN-LAST:event_cmdCrearActionPerformed

    private void cmdBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdBuscarActionPerformed
        Conexion conexion = new Conexion();
        Persona per = new Persona();
        try {

            per = conexion.buscarPersona(this.txtcedula.getText());


            if (per == null) {
                JOptionPane.showMessageDialog(this, "No se encontro el exalumno con la Cedula: " + this.txtcedula.getText());

                DefaultTableModel temp = (DefaultTableModel) tablaTelefonos.getModel();
                for (int i = tablaTelefonos.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }
                temp = (DefaultTableModel) tablaCorreos.getModel();
                for (int i = tablaCorreos.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }

            } else {

                this.txtnombres.setText(per.getNombres());
                this.txtapellidos.setText(per.getApellidos());
                this.txtdireccion.setText(per.getDireccion());

                this.txtclave.setText(conexion.buscarClave(this.txtcedula.getText()));
                per.setCorreos(conexion.buscarCorreos(per.getCedula()));
                per.setTelefonos(conexion.buscarTelefonos(per.getCedula()));
                correos = per.getCorreos();
                telefonos = per.getTelefonos();



                DefaultTableModel temp = (DefaultTableModel) tablaCorreos.getModel();
                for (int i = tablaCorreos.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }
                for (int i = 0; i < correos.size(); i++) {

                    Object nuevo[] = {correos.get(i)}; //esto es por las tres columnas aunque puede variar

                    temp.addRow(nuevo);
                }
                tablaCorreos.setModel(temp);


                temp = (DefaultTableModel) tablaTelefonos.getModel();
                for (int i = tablaTelefonos.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }
                for (int i = 0; i < telefonos.size(); i++) {

                    Object nuevo[] = {telefonos.get(i)}; //esto es por las tres columnas aunque puede variar

                    temp.addRow(nuevo);
                }
                tablaTelefonos.setModel(temp);
                
                String ciudad=conexion.buscarCiudad(this.txtcedula.getText());
                if(ciudad.equalsIgnoreCase(""))
                    ciudad="Elija una ciudad...";
                int metodo=conexion.obtenerTipoContacto(this.txtcedula.getText());
                if (metodo==5)
                    metodo=0;
                
                this.cmbciudad.setSelectedItem(ciudad);
                this.txtTelefonoPrincipal.setText(conexion.ObtenerTelefonoPrincipal(this.txtcedula.getText()));
                this.txtCorreoPrincipal.setText(conexion.ObtenerCorreoPrincipal(this.txtcedula.getText()));
                this.cmbMetodoContacto.setSelectedIndex(metodo);
                if(metodo==3)
                {
                    this.txtMetodoC.setText(conexion.ObtenerOtro(this.txtcedula.getText()));
                    this.txtMetodoC.setEditable(true);
                }
                else
                {
                    this.txtMetodoC.setEditable(false);
                }
                
                this.cmbExContactado.setSelectedItem(conexion.obtenerEstado(this.txtcedula.getText()));
                
                
                
                if(conexion.buscarExalumno(this.txtcedula.getText()))
                {
                    this.cmbTipoUsuario.setSelectedIndex(4);
                    String esc=conexion.buscarEscuelaCedula(this.txtcedula.getText());
                    this.cmbTipoEscuela.setSelectedItem(esc);
                    this.cmbTipoFacultad.setSelectedItem(conexion.buscarFacultadEscuela(esc));
                    this.cmbTipoEscuela.setSelectedItem(esc);
                    
                }
                if(conexion.buscarAdministrador(this.txtcedula.getText()))
                {
                     this.cmbTipoUsuario.setSelectedIndex(1);
                }
                if(conexion.buscarAyudante(this.txtcedula.getText()))
                {
                     this.cmbTipoUsuario.setSelectedIndex(3);
                }
                deshabilitarTipoUsuario();
                this.cmdNuevo.setEnabled(true);
                this.cmdModificar.setEnabled(true);
                this.cmdCrear.setEnabled(false);
                
            }

        } catch (SQLException ex) {
            Logger.getLogger("Error de conexion con la base de datos");
        }

    }//GEN-LAST:event_cmdBuscarActionPerformed

    private void txttelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txttelefonoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txttelefonoActionPerformed

    private void txtcorreoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcorreoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtcorreoActionPerformed

    private void txtapellidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtapellidosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtapellidosActionPerformed

    private void txtnombresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtnombresActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtnombresActionPerformed

    private void txtcedulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcedulaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtcedulaActionPerformed

    private void cmbfacultadesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbfacultadesActionPerformed
        Conexion conexion=new Conexion();
        ArrayList lista;
        try {
            lista=conexion.listarEscuelas(String.valueOf(this.cmbfacultades.getSelectedItem()));
            this.cmbescuelas.removeAllItems();
            this.cmbescuelas.addItem("Escuela");
            for (int i=0; i<lista.size();i++)
            {
                this.cmbescuelas.addItem(lista.get(i));
            } 
            
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cmbfacultadesActionPerformed

    private void cmbescuelasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbescuelasActionPerformed
        
            
    }//GEN-LAST:event_cmbescuelasActionPerformed

    private void cmbmetodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbmetodoActionPerformed
        
    }//GEN-LAST:event_cmbmetodoActionPerformed

    private void cmbcontactadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbcontactadoActionPerformed
        
        
    }//GEN-LAST:event_cmbcontactadoActionPerformed

    private void cmdreporteEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdreporteEActionPerformed
        Conexion conexion=new Conexion();
        
        
        DefaultTableModel temp = (DefaultTableModel) tablaPorEscuela.getModel();
        for (int i = tablaPorEscuela.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        tablaPorEscuela.setModel(temp);
        temp = (DefaultTableModel) tablaPorEscuela.getModel();
        try {
            tablaPorEscuela.setModel(conexion.reportePorEscuela(temp));
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
            
                
        
    }//GEN-LAST:event_cmdreporteEActionPerformed

    private void cmdreporteFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdreporteFActionPerformed
                Conexion conexion=new Conexion();
        
        
        DefaultTableModel temp = (DefaultTableModel) tablaPorFacultad.getModel();
        for (int i = tablaPorFacultad.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        tablaPorFacultad.setModel(temp);
        temp = (DefaultTableModel) tablaPorFacultad.getModel();
        try {
            tablaPorFacultad.setModel(conexion.reportePorFacultad(temp));
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cmdreporteFActionPerformed

    private void cmdNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNuevoActionPerformed
       vaciarCampos();
       habilitarTipoUsuario();
       this.cmdNuevo.setEnabled(true);
       this.cmdModificar.setEnabled(false);
       this.cmdCrear.setEnabled(true);
    }//GEN-LAST:event_cmdNuevoActionPerformed

    private void cmbbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbbuscarActionPerformed
       habilitarOrden();
       this.cmbfacultades.setSelectedItem("Facultad");
       this.cmbescuelas.setSelectedItem("Escuela");
       this.cmbmetodo.setSelectedItem("Metodo de Contacto");
       this.cmbcontactado.setSelectedItem("Estado");
       

    }//GEN-LAST:event_cmbbuscarActionPerformed

    private void cmbfacultadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbfacultadActionPerformed
            Conexion conexion=new Conexion();
            ArrayList lista;
        try {
            lista=conexion.listarEscuelas(String.valueOf(this.cmbfacultad.getSelectedItem()));
            for (int i=0; i<lista.size();i++)
            {
                this.cmbescuela.addItem(lista.get(i));
            }
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
 
        
        this.cmbescuela.setEnabled(true);
    }//GEN-LAST:event_cmbfacultadActionPerformed

    private void cmbescuelaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbescuelaActionPerformed
        this.cmdasignarF.setEnabled(true);
    }//GEN-LAST:event_cmbescuelaActionPerformed

    private void txtcedula1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcedula1ActionPerformed
        
        
    }//GEN-LAST:event_txtcedula1ActionPerformed

    private void cmdasignarCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdasignarCActionPerformed
        String id_encuesta = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        String titulo = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 1));
        String cedula=this.txtcedula1.getText();
        
        Conexion conexion=new Conexion();
        try {
            if(!conexion.comprobarAsignacion(id_encuesta,cedula))
            {
                conexion.asignarEncuesta(id_encuesta,cedula);
                JOptionPane.showMessageDialog(this, "Asignacion realizada");
                log.ingersarLog(this.cedulaActual,"ACCESO: "+titulo+" USUARIO: "+this.cedulaActual);
                
            }
            else
            {
                JOptionPane.showMessageDialog(this, "Asignacion ya existe");
            }
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.txtcedula1.setText(null);
    }//GEN-LAST:event_cmdasignarCActionPerformed

    private void txtcedula1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcedula1KeyPressed
        this.cmdasignarC.setEnabled(true);
    }//GEN-LAST:event_txtcedula1KeyPressed

    private void cmdasignarFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdasignarFActionPerformed
        Conexion conexion=new Conexion();
        String id_encuesta = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
         String titulo = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 1));
        //String cadUsuarios="";
         try {
            ArrayList<String> lista=conexion.listarCedulaExalumnos((String)this.cmbfacultad.getSelectedItem(),(String)this.cmbescuela.getSelectedItem());
            for(int i=0;i<lista.size();i++)
            {
               if(!conexion.comprobarAsignacion(id_encuesta,lista.get(i)))
                {
                    conexion.asignarEncuesta(id_encuesta,lista.get(i));
                    //cadUsuarios=lista.get(i)+cadUsuarios+" - ";
                
                }
            }
            JOptionPane.showMessageDialog(this, "Asignacion realizada");
            log.ingersarLog(this.cedulaActual,"ACCESO " +titulo+" FACULTAD: "+(String)this.cmbfacultad.getSelectedItem()+" "+" ESCUELA: "+(String)this.cmbescuela.getSelectedItem());
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.cmbfacultad.setSelectedItem("Seleccione una facultad...");
        this.cmbescuela.setSelectedItem("Seleccione una escuela...");
        this.cmbescuela.setEnabled(false);
        this.cmdasignarF.setEnabled(false);
    }//GEN-LAST:event_cmdasignarFActionPerformed

    private void cmdsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdsalirActionPerformed
        Conexion log = new Conexion();
        try
        {
            log.ingersarLog(cedulaActual, "SALIO ADMINISTRADOR");
        } 
        catch (SQLException ex) 
        {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        Principal principal=new Principal();
        principal.setVisible(true);
        this.dispose();
        
    }//GEN-LAST:event_cmdsalirActionPerformed

    private void cmddesasignarCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmddesasignarCActionPerformed
         String id_encuesta = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        String cedula=this.txtcedula1.getText();
        
        Conexion conexion=new Conexion();
        try {
            if(conexion.comprobarAsignacion(id_encuesta,cedula))
            {
                conexion.desasignarEncuesta(id_encuesta,cedula);
                JOptionPane.showMessageDialog(this, "Asignacion realizada");
                
            }
            else
            {
                JOptionPane.showMessageDialog(this, "Asignacion no existe");
            }
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.txtcedula1.setText(null);
    }//GEN-LAST:event_cmddesasignarCActionPerformed

    private void cmddesasignarFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmddesasignarFActionPerformed
        Conexion conexion=new Conexion();
        String id_encuesta = String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        
        try {
            ArrayList<String> lista=conexion.listarCedulaExalumnos((String)this.cmbfacultad.getSelectedItem(),(String)this.cmbescuela.getSelectedItem());
            for(int i=0;i<lista.size();i++)
            {
               if(conexion.comprobarAsignacion(id_encuesta,lista.get(i)))
            {
                conexion.desasignarEncuesta(id_encuesta,lista.get(i));
                
                
            }
            }
            JOptionPane.showMessageDialog(this, "Asignacion realizada");
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.cmbfacultad.setSelectedItem("Seleccione una facultad...");
        this.cmbescuela.setSelectedItem("Seleccione una escuela...");
        this.cmbescuela.setEnabled(false);
        this.cmdasignarF.setEnabled(false);
    }//GEN-LAST:event_cmddesasignarFActionPerformed

    private void cmdmodificarEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdmodificarEActionPerformed
        banderaE=1;
        String id_encuesta = null;
        id_encuesta=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        if (id_encuesta==null)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado una encuesta.");
        }
        else
        {
            
            Encuesta nueva = new Encuesta();
            for (int i=0;i<this.listaEncuestas.size();i++)
            {
                nueva=listaEncuestas.get(i);
                if (nueva.getId()==Integer.parseInt(id_encuesta))
                {
                    this.txtTitulo.setText(nueva.getTitulo());
                    this.txtCabecera.setText(nueva.getCabecera());
                    this.txtDespedida.setText(nueva.getDespedida());
                }
            }
            this.titAnt=this.txtTitulo.getText();
            this.cabAnt=this.txtCabecera.getText();
            this.despAnt=this.txtDespedida.getText();
            dlgmodificar.setSize(550, 450);
            dlgmodificar.setLocationRelativeTo(this);
            dlgmodificar.setModal(true);
            dlgmodificar.setVisible(true);
        }
        
        
        
    }//GEN-LAST:event_cmdmodificarEActionPerformed

    private void cmddeshabilitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmddeshabilitarActionPerformed
        String id_encuesta = null;
        id_encuesta=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        String titulo=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 1));
        if (id_encuesta==null)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado una encuesta.");
        }
        else
        {
            Conexion conexion=new Conexion();
            try {
                    conexion.modificarEstadoEncuesta(id_encuesta,0);
                    actualizarTablaEncuestas();
                    
                    log.ingersarLog(this.cedulaActual, "DESHABILITADA: "+titulo);
                    JOptionPane.showMessageDialog(this, "Encuesta "+ titulo+ " deshabilitada");
            } catch (SQLException ex) {
                Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_cmddeshabilitarActionPerformed

    private void cmdhabilitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdhabilitarActionPerformed
        String id_encuesta = null;
        id_encuesta=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        String titulo=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 1));
        if (id_encuesta==null)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado una encuesta.");
        }
        else
        {
            Conexion conexion=new Conexion();
            try {
                    conexion.modificarEstadoEncuesta(id_encuesta,1);
                    actualizarTablaEncuestas();
                    
                    log.ingersarLog(this.cedulaActual, "HABILITADA: "+titulo);
                    JOptionPane.showMessageDialog(this, "Encuesta "+ titulo+ " habilitada");
                    
            } catch (SQLException ex) {
                Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
    }//GEN-LAST:event_cmdhabilitarActionPerformed

    private void cmdeliminarEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdeliminarEActionPerformed
        String id_encuesta = null;
        id_encuesta=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        String titulo=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 1));
        if (id_encuesta==null)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado una encuesta.");
        }
        else
        {
            Conexion conexion=new Conexion();
            try {
                    if(!conexion.comprobarEncuestaLlenada(id_encuesta))
                    {
                        conexion.eliminarEncuesta(id_encuesta);
                        actualizarTablaEncuestas();
                        log.ingersarLog(this.cedulaActual, "ELIMINADA: "+titulo);
                        JOptionPane.showMessageDialog(this, "Encuesta "+ titulo+ " eliminada");
                    }
                    else
                    {
                        JOptionPane.showMessageDialog(this, "Encuesta ya ha sido llenada. No es posible eliminar.");
                    }
            } catch (SQLException ex) {
                //Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(this, "Encuesta ya ha sido llenada. No es posible eliminar.");
                
            }
        }
        
    
    }//GEN-LAST:event_cmdeliminarEActionPerformed

    private void cmdcancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdcancelarActionPerformed
        dlgmodificar.dispose();
    }//GEN-LAST:event_cmdcancelarActionPerformed

    private void cmdmodificarDescripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdmodificarDescripcionActionPerformed
        if (banderaE==1)
        {
        String cabecera=this.txtCabecera.getText();
        String titulo=this.txtTitulo.getText();
        String despedida = this.txtDespedida.getText();
        String id_encuesta=id_encuesta=String.valueOf(tablaEncuesta.getValueAt(tablaEncuesta.getSelectedRow(), 0));
        Conexion conexion=new Conexion();
        try {
                // conexion.modificarDescripcionEncuesta(id_encuesta,despedida);
            if (!cabecera.equalsIgnoreCase(cabAnt))
                log.ingersarLog(this.cedulaActual, "MODIFICACION CABECERA "+titulo);
            if (!despedida.equalsIgnoreCase(despAnt))
                log.ingersarLog(this.cedulaActual, "MODIFICACION DESPEDIDA "+titulo);
            if (!titulo.equalsIgnoreCase(titAnt))
                log.ingersarLog(this.cedulaActual, "MODIFICACION TITULO "+titAnt+" a "+titulo);
                conexion.modificarDescripcionEncuesta(id_encuesta,titulo,cabecera,despedida);
             actualizarTablaEncuestas();
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        }
        if (banderaE==2)
        {
        String cabecera=this.txtCabecera.getText();
        String titulo=this.txtTitulo.getText();
        String despedida = this.txtDespedida.getText();
        Conexion conexion=new Conexion();
        try {
            conexion.crearEncuesta(titulo,cabecera,despedida);
            actualizarTablaEncuestas();
            log.ingersarLog(this.cedulaActual, "CREACION "+titulo);
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        }
        
        dlgmodificar.dispose();  
    }//GEN-LAST:event_cmdmodificarDescripcionActionPerformed

    private void cmdcrearEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdcrearEActionPerformed
            banderaE=2;
            dlgmodificar.setSize(550, 450);
            dlgmodificar.setLocationRelativeTo(this);
            dlgmodificar.setModal(true);
            dlgmodificar.setVisible(true);
        
    }//GEN-LAST:event_cmdcrearEActionPerformed

    private void cmdverInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdverInfoActionPerformed
        String cedula = null;
        cedula=String.valueOf(tablaConsulta.getValueAt(tablaConsulta.getSelectedRow(), 2));
        if (cedula==null)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado un estudiante.");
        }
        else
        {
            InterfazExAlumno exa;
            try {
                exa = new InterfazExAlumno();
                exa.setVisible(true);
                exa.enviarCedula(cedula,1);
            } catch (SQLException ex) {
                Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        }
    }//GEN-LAST:event_cmdverInfoActionPerformed

    private void cmbTipoUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTipoUsuarioActionPerformed
        Conexion conexion=new Conexion();
        ArrayList<String> lista;
        if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Administrador General") || String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Ayudante")){
        
            this.cmbTipoFacultad.setEnabled(false);
            this.cmbTipoEscuela.setEnabled(false);
            this.cmdAgregarFacultad.setEnabled(false);
            this.cmdQuitarFacultad.setEnabled(false);
            this.tablaElegirFacultad.setEnabled(false);
            
        } 
        if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Administrador por Facultad") || String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Exalumno"))
        {        
        try {
            this.cmbTipoFacultad.removeAllItems();
            this.cmbTipoFacultad.addItem("Facultad");
            lista = conexion.listarFacultades();
            for (int i=0; i<lista.size();i++)
                {
                    this.cmbTipoFacultad.addItem(lista.get(i));         

                }
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        
            this.cmbTipoFacultad.setEnabled(true);
            this.cmbTipoEscuela.setEnabled(false);
        }

    }//GEN-LAST:event_cmbTipoUsuarioActionPerformed

    private void cmbTipoFacultadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTipoFacultadActionPerformed
        Conexion conexion=new Conexion();
        ArrayList<String> lista;
        if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Exalumno"))
        {
        try {
            lista = conexion.listarEscuelas(String.valueOf(this.cmbTipoFacultad.getSelectedItem()));
            for (int i=0; i<lista.size();i++)
                {
                    this.cmbTipoEscuela.addItem(lista.get(i));         

                }
            this.cmbTipoEscuela.setEnabled(true);
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        }
        if(String.valueOf(this.cmbTipoUsuario.getSelectedItem()).equalsIgnoreCase("Administrador por Facultad"))
        {
            this.cmdAgregarFacultad.setEnabled(true);
            this.cmdQuitarFacultad.setEnabled(true);
            this.tablaElegirFacultad.setEnabled(true);
        }
            
    }//GEN-LAST:event_cmbTipoFacultadActionPerformed

    private void cmbTipoEscuelaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTipoEscuelaActionPerformed
        this.cmdAgregarFacultad.setEnabled(true);
        this.cmdQuitarFacultad.setEnabled(true);
        this.tablaElegirFacultad.setEnabled(true);
    }//GEN-LAST:event_cmbTipoEscuelaActionPerformed

    private void cmdQuitarFacultadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdQuitarFacultadActionPerformed
        int indice=tablaElegirFacultad.getSelectedRow();
        if (indice==-1)
        {
            JOptionPane.showMessageDialog(this, "No ha seleccionado una fila.");
        }
        else
        {
        DefaultTableModel temp=(DefaultTableModel) tablaElegirFacultad.getModel();
        temp.removeRow(indice);
        tablaElegirFacultad.setModel(temp);
        }
    }//GEN-LAST:event_cmdQuitarFacultadActionPerformed

    private void cmdAgregarFacultadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAgregarFacultadActionPerformed
        String facultad=(String) this.cmbTipoFacultad.getSelectedItem();
        String escuela=(String) this.cmbTipoEscuela.getSelectedItem();
        if(escuela.equalsIgnoreCase("Escuela")){
            escuela="Todas";
        }
            
        DefaultTableModel temp=(DefaultTableModel) tablaElegirFacultad.getModel();
        Object nuevo[]={facultad,escuela};
        temp.addRow(nuevo);
        tablaElegirFacultad.setModel(temp);
        try {
            cargarCombosTipoUsuario();
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cmdAgregarFacultadActionPerformed

    private void cmdTelefonoPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdTelefonoPrincipalActionPerformed
        int sel = -3;
        sel = Integer.parseInt(String.valueOf(tablaTelefonos.getSelectedRow()));
        if (sel == -1 ){
            JOptionPane.showMessageDialog(this, "Seleccione una fila");
        } else {
            txtTelefonoPrincipal.setText(String.valueOf(tablaTelefonos.getValueAt(tablaTelefonos.getSelectedRow(), 0)));
            
        }
    }//GEN-LAST:event_cmdTelefonoPrincipalActionPerformed

    private void cmdCorreoPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCorreoPrincipalActionPerformed
        int sel = -3;
        sel = Integer.parseInt(String.valueOf(tablaCorreos.getSelectedRow()));
        if (sel == -1 ){
            JOptionPane.showMessageDialog(this, "Seleccione una fila");
        } else {
            txtCorreoPrincipal.setText(String.valueOf(tablaCorreos.getValueAt(tablaCorreos.getSelectedRow(), 0)));
            
        }
    }//GEN-LAST:event_cmdCorreoPrincipalActionPerformed

    private void cmbescuelasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmbescuelasMouseClicked
        
    }//GEN-LAST:event_cmbescuelasMouseClicked

    private void cmbfacultadesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmbfacultadesMouseClicked
       
    }//GEN-LAST:event_cmbfacultadesMouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String fac=(String) this.cmbfacultades.getSelectedItem();
        if(!fac.equalsIgnoreCase("Facultad"))
        {
        
        DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            
            String facultad;
            for (int i=0;i<auxReporteFacultad.getRowCount();i++)
            {
                facultad=(String) auxReporteFacultad.getValueAt(i, 0);
                if(facultad.equalsIgnoreCase((String)cmbfacultades.getSelectedItem()))
                {
                    Object nuevo[]={auxReporteFacultad.getValueAt(i, 0),auxReporteFacultad.getValueAt(i, 1),auxReporteFacultad.getValueAt(i, 2),auxReporteFacultad.getValueAt(i, 3),auxReporteFacultad.getValueAt(i, 4),auxReporteFacultad.getValueAt(i, 5),auxReporteFacultad.getValueAt(i, 6),auxReporteFacultad.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
                }
            }

            auxReporteEscuela=temp2;
            auxReporteMetodo=temp2;
            auxReporteEstado=temp2;
            tablaConsulta.setModel(temp2);
            
            
        }
        
        String esc=(String) this.cmbescuelas.getSelectedItem();
        if(!esc.equalsIgnoreCase("Escuela"))
        {
        String escuela;
          
           
            DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            
            
            for (int i=0;i<auxReporteEscuela.getRowCount();i++)
            {
                escuela=(String) auxReporteEscuela.getValueAt(i, 1);
                if(escuela.equalsIgnoreCase((String)cmbescuelas.getSelectedItem()))
                {
                    Object nuevo[]={auxReporteEscuela.getValueAt(i, 0),auxReporteEscuela.getValueAt(i, 1),auxReporteEscuela.getValueAt(i, 2),auxReporteEscuela.getValueAt(i, 3),auxReporteEscuela.getValueAt(i, 4),auxReporteEscuela.getValueAt(i, 5),auxReporteEscuela.getValueAt(i, 6),auxReporteEscuela.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
                }
            }
            
            auxReporteMetodo=temp2;
            auxReporteEstado=temp2;
            tablaConsulta.setModel(temp2);
            
        }
        
        String met=(String) this.cmbmetodo.getSelectedItem();
        if(!met.equalsIgnoreCase("Metodo de Contacto"))
        {   

            DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            String metodo;
            
            for (int i=0;i<auxReporteMetodo.getRowCount();i++)
            {
                metodo=(String) auxReporteMetodo.getValueAt(i, 5);
                if(met.equalsIgnoreCase(metodo))
                {
                    Object nuevo[]={auxReporteMetodo.getValueAt(i, 0),auxReporteMetodo.getValueAt(i, 1),auxReporteMetodo.getValueAt(i, 2),auxReporteMetodo.getValueAt(i, 3),auxReporteMetodo.getValueAt(i, 4),auxReporteMetodo.getValueAt(i, 5),auxReporteMetodo.getValueAt(i, 6),auxReporteMetodo.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
                }
            }

            auxReporteEstado=temp2;
            tablaConsulta.setModel(temp2);
            

        }
        else
        {
            if(fac.equalsIgnoreCase("Facultad"))
            {
                DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            
            String facultad;
            for (int i=0;i<auxReporteFacultad.getRowCount();i++)
            {
                    Object nuevo[]={auxReporteFacultad.getValueAt(i, 0),auxReporteFacultad.getValueAt(i, 1),auxReporteFacultad.getValueAt(i, 2),auxReporteFacultad.getValueAt(i, 3),auxReporteFacultad.getValueAt(i, 4),auxReporteFacultad.getValueAt(i, 5),auxReporteFacultad.getValueAt(i, 6),auxReporteFacultad.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
            }

            auxReporteEstado=temp2;
            tablaConsulta.setModel(temp2);
            }
        }
        String contac=(String) this.cmbcontactado.getSelectedItem();
        if(!contac.equalsIgnoreCase("Estado"))
        {
        Conexion conexion=new Conexion();
                
            if(contac.equalsIgnoreCase("contactado"))
            {
                contac="SI";
            }
            else
            {
                contac="NO";
            }
            String contacto;
          
           
            DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            
            
            for (int i=0;i<auxReporteEstado.getRowCount();i++)
            {
                contacto=(String) auxReporteEstado.getValueAt(i, 7);
                if(contacto.equalsIgnoreCase(contac))
                {
                    Object nuevo[]={auxReporteEstado.getValueAt(i, 0),auxReporteEstado.getValueAt(i, 1),auxReporteEstado.getValueAt(i, 2),auxReporteEstado.getValueAt(i, 3),auxReporteEstado.getValueAt(i, 4),auxReporteEstado.getValueAt(i, 5),auxReporteEstado.getValueAt(i, 6),auxReporteEstado.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
                }
            }

            
            tablaConsulta.setModel(temp2);

        
        
        }
        else
        {
            if(fac.equalsIgnoreCase("Facultad") && met.equalsIgnoreCase("Metodo de Contacto") )
            {
                DefaultTableModel temp2=new DefaultTableModel();
            temp2.addColumn("FACULTAD");
            temp2.addColumn("ESCUELA");
            temp2.addColumn("CEDULA");
            temp2.addColumn("NOMBRES");
            temp2.addColumn("APELLIDOS");
            temp2.addColumn("METODO_CONTACTO");
            temp2.addColumn("CONTACTO");
            temp2.addColumn("CONTACTADO");
            
            String facultad;
            for (int i=0;i<auxReporteFacultad.getRowCount();i++)
            {
                    Object nuevo[]={auxReporteFacultad.getValueAt(i, 0),auxReporteFacultad.getValueAt(i, 1),auxReporteFacultad.getValueAt(i, 2),auxReporteFacultad.getValueAt(i, 3),auxReporteFacultad.getValueAt(i, 4),auxReporteFacultad.getValueAt(i, 5),auxReporteFacultad.getValueAt(i, 6),auxReporteFacultad.getValueAt(i, 7)};
                    temp2.addRow(nuevo);
            }
            
            tablaConsulta.setModel(temp2);
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cmdAgregarCiudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAgregarCiudadActionPerformed
            dlgciudad.setSize(360, 220);
            dlgciudad.setLocationRelativeTo(this);
            dlgciudad.setModal(true);
            dlgciudad.setVisible(true);
    }//GEN-LAST:event_cmdAgregarCiudadActionPerformed

    private void txtnuevaCiudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtnuevaCiudadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtnuevaCiudadActionPerformed

    private void cmdmodificarDescripcion1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdmodificarDescripcion1ActionPerformed
        String ciudad=this.txtnuevaCiudad.getText();
        Conexion conexion=new Conexion();
        try {
            conexion.agregarCiudad(ciudad);

        this.cmbciudad.removeAllItems();
        this.cmbciudad.addItem("Elija una ciudad...");
        ArrayList lista=conexion.listarCiudades();
        for (int i=0; i<lista.size();i++)
        {
            this.cmbciudad.addItem(lista.get(i));         
            
        }
        } catch (SQLException ex) {
            Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
        dlgciudad.dispose();
    }//GEN-LAST:event_cmdmodificarDescripcion1ActionPerformed

    private void cmdcancelar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdcancelar1ActionPerformed
        dlgciudad.dispose();
    }//GEN-LAST:event_cmdcancelar1ActionPerformed

    private void cmbMetodoContactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbMetodoContactoActionPerformed
        if(this.cmbMetodoContacto.getSelectedIndex()==3)
        {
            this.txtMetodoC.setEditable(true);
        }
    }//GEN-LAST:event_cmbMetodoContactoActionPerformed

    private void cmbExContactadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbExContactadoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbExContactadoActionPerformed


    private void txtTituloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTituloActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTituloActionPerformed

    /**
     * @param args the command line arguments
     */
    
    public void cargarCombos() throws SQLException{
        Conexion conexion=new Conexion();
        ArrayList<String> lista=conexion.listarFacultades();
        for (int i=0; i<lista.size();i++)
        {
            this.cmbfacultades.addItem(lista.get(i));
            this.cmbfacultad.addItem(lista.get(i));          
            
        }
        
        lista=conexion.listarCiudades();
        for (int i=0; i<lista.size();i++)
        {
            this.cmbciudad.addItem(lista.get(i));         
            
        }
        this.cmbescuelas.setEnabled(false);
        cmbmetodo.setEnabled(false);
        cmbcontactado.setEnabled(false);
        cmbfacultades.setEnabled(false);
        this.cmbescuela.setEnabled(false);
        this.cmdasignarC.setEnabled(false);
        this.cmdasignarF.setEnabled(false);
        this.cmbTipoFacultad.setEnabled(false);
        this.cmbTipoEscuela.setEnabled(false);
        
        this.cmdAgregarFacultad.setEnabled(false);
        this.cmdQuitarFacultad.setEnabled(false);
        this.tablaElegirFacultad.setEnabled(false);
        
        actualizarTablaEncuestas();
        
    }
    
    public void actualizarTablaEncuestas() throws SQLException{
        Conexion conexion=new Conexion();
        DefaultTableModel temp = (DefaultTableModel) tablaEncuesta.getModel();
        
        listaEncuestas=conexion.listarEncuestas();
        for (int i = tablaEncuesta.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        
        for (int i = 0; i < listaEncuestas.size(); i++) {
                Encuesta nueva = new Encuesta();
               nueva = (Encuesta) listaEncuestas.get(i);
                Object nuevo[] = {nueva.getId(), nueva.getTitulo(), nueva.getEstado()}; //esto es por las tres columnas aunque puede variar
                temp.addRow(nuevo);
            }
            //tblClientes.setModel(temp);
        
        tablaEncuesta.setModel(temp);
        
        //tablaEncuesta.setModel(conexion.listarEncuestas((DefaultTableModel)tablaEncuesta.getModel()));
    }
    
    public void vaciarCampos(){
        this.txtcedula.setText(null);
        this.txtclave.setText(null);
        this.txtnombres.setText(null);
        this.txtapellidos.setText(null);
        this.txtdireccion.setText(null);
        this.txttelefono.setText(null);
        this.txtcorreo.setText(null);
        this.txtCorreoPrincipal.setText(null);
        this.txtTelefonoPrincipal.setText(null);
        this.txtMetodoC.setText(null);
        
        DefaultTableModel temp = (DefaultTableModel) tablaCorreos.getModel();
        for (int i = tablaCorreos.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        this.tablaCorreos.setModel(temp);
        DefaultTableModel temp1 = (DefaultTableModel) tablaTelefonos.getModel();
        for (int i = tablaTelefonos.getRowCount() - 1; i >= 0; i--) {
            temp1.removeRow(i);
        }
        this.tablaTelefonos.setModel(temp1);
        DefaultTableModel temp2 = (DefaultTableModel) tablaElegirFacultad.getModel();
        for (int i = tablaElegirFacultad.getRowCount() - 1; i >= 0; i--) {
            temp2.removeRow(i);
        }
        this.tablaElegirFacultad.setModel(temp2);
        
        this.cmbTipoUsuario.setSelectedItem("Ninguno");
        this.cmbTipoFacultad.setSelectedItem("Facultad");
        this.cmbTipoEscuela.setSelectedItem("Escuela");
        this.cmbTipoFacultad.setEnabled(false);
        this.cmbTipoEscuela.setEnabled(false);
        this.cmdAgregarFacultad.setEnabled(false);
        this.cmdQuitarFacultad.setEnabled(false);
        this.tablaElegirFacultad.setEnabled(false);
        this.cmbciudad.setSelectedIndex(0);
        this.cmbMetodoContacto.setSelectedIndex(0);
        this.cmbExContactado.setSelectedIndex(0);
        
    }
    
    
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InterfazAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InterfazAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InterfazAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InterfazAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new InterfazAdmin().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(InterfazAdmin.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox chkapellidos;
    private javax.swing.JCheckBox chkcedula;
    private javax.swing.JCheckBox chkcontactado;
    private javax.swing.JCheckBox chkcontacto;
    private javax.swing.JCheckBox chkescuela;
    private javax.swing.JCheckBox chkfacultad;
    private javax.swing.JCheckBox chkmetodo;
    private javax.swing.JCheckBox chknombres;
    private javax.swing.JComboBox cmbExContactado;
    private javax.swing.JComboBox cmbMetodoContacto;
    private javax.swing.JComboBox cmbTipoEscuela;
    private javax.swing.JComboBox cmbTipoFacultad;
    private javax.swing.JComboBox cmbTipoUsuario;
    private javax.swing.JComboBox cmbbuscar;
    private javax.swing.JComboBox cmbciudad;
    private javax.swing.JComboBox cmbcontactado;
    private javax.swing.JComboBox cmbescuela;
    private javax.swing.JComboBox cmbescuelas;
    private javax.swing.JComboBox cmbfacultad;
    private javax.swing.JComboBox cmbfacultades;
    private javax.swing.JComboBox cmbmetodo;
    private javax.swing.JButton cmdActualizar;
    private javax.swing.JButton cmdAgregarC;
    private javax.swing.JButton cmdAgregarCiudad;
    private javax.swing.JButton cmdAgregarFacultad;
    private javax.swing.JButton cmdAgregarT;
    private javax.swing.JButton cmdBuscar;
    private javax.swing.JButton cmdCorreoPrincipal;
    private javax.swing.JButton cmdCrear;
    private javax.swing.JButton cmdModificar;
    private javax.swing.JButton cmdNuevo;
    private javax.swing.JButton cmdQuitarFacultad;
    private javax.swing.JButton cmdTelefonoPrincipal;
    private javax.swing.JButton cmdasignarC;
    private javax.swing.JButton cmdasignarF;
    private javax.swing.JButton cmdcancelar;
    private javax.swing.JButton cmdcancelar1;
    private javax.swing.JButton cmdcrearE;
    private javax.swing.JButton cmddesasignarC;
    private javax.swing.JButton cmddesasignarF;
    private javax.swing.JButton cmddeshabilitar;
    private javax.swing.JButton cmdeliminarC;
    private javax.swing.JButton cmdeliminarE;
    private javax.swing.JButton cmdeliminarT;
    private javax.swing.JButton cmdhabilitar;
    private javax.swing.JButton cmdmodificarDescripcion;
    private javax.swing.JButton cmdmodificarDescripcion1;
    private javax.swing.JButton cmdmodificarE;
    private javax.swing.JButton cmdreporteE;
    private javax.swing.JButton cmdreporteF;
    private javax.swing.JButton cmdsalir;
    private javax.swing.JButton cmdverInfo;
    private javax.swing.JDialog dlgciudad;
    private javax.swing.JDialog dlgmodificar;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblusuario;
    private javax.swing.JTable tablaConsulta;
    private javax.swing.JTable tablaCorreos;
    private javax.swing.JTable tablaElegirFacultad;
    private javax.swing.JTable tablaEncuesta;
    private javax.swing.JTable tablaPorEscuela;
    private javax.swing.JTable tablaPorFacultad;
    private javax.swing.JTable tablaTelefonos;
    private javax.swing.JTextPane txtCabecera;
    private javax.swing.JTextField txtCorreoPrincipal;
    private javax.swing.JTextPane txtDespedida;
    private javax.swing.JTextField txtMetodoC;
    private javax.swing.JTextField txtTelefonoPrincipal;
    private javax.swing.JTextField txtTitulo;
    private javax.swing.JTextField txtapellidos;
    private javax.swing.JTextField txtcampo;
    private javax.swing.JTextField txtcedula;
    private javax.swing.JTextField txtcedula1;
    private javax.swing.JTextField txtclave;
    private javax.swing.JTextField txtcorreo;
    private javax.swing.JTextField txtdireccion;
    private javax.swing.JTextField txtnombres;
    private javax.swing.JTextField txtnuevaCiudad;
    private javax.swing.JTextField txttelefono;
    // End of variables declaration//GEN-END:variables

    private String verificarOrden() {
        String cadena=" ORDER BY";
        if(chkfacultad.isSelected())
        {
            cadena=cadena+" FACULTAD,";
        }
        if(chkescuela.isSelected())
        {
            cadena=cadena+" ESCUELA,";
        }
        if(chkcedula.isSelected())
        {
            cadena=cadena+" CEDULA,";
        }
        if(this.chknombres.isSelected())
        {
            cadena=cadena+" NOMBRES,";
        }
        if(chkapellidos.isSelected())
        {
            cadena=cadena+" APELLIDOS,";
        }
        if(chkmetodo.isSelected())
        {
            cadena=cadena+" METODO_CONTACTO,";
        }
        if(chkcontacto.isSelected())
        {
            cadena=cadena+" CONTACTO,";
        }
        if(chkcontactado.isSelected())
        {
            cadena=cadena+" CONTACTADO,";
        }
        
        deshabilitarOrden();
        
        
        return cadena;
       
    }

    private void deshabilitarOrden() {
        this.chkcedula.setEnabled(false);
        this.chknombres.setEnabled(false);
        this.chkapellidos.setEnabled(false);
        this.chkfacultad.setEnabled(false);
        this.chkescuela.setEnabled(false);
        this.chkmetodo.setEnabled(false);
        this.chkcontacto.setEnabled(false);
        this.chkcontactado.setEnabled(false);
    }

    private void habilitarOrden() {
        this.chkcedula.setEnabled(true);
        this.chknombres.setEnabled(true);
        this.chkapellidos.setEnabled(true);
        this.chkfacultad.setEnabled(true);
        this.chkescuela.setEnabled(true);
        this.chkmetodo.setEnabled(true);
        this.chkcontacto.setEnabled(true);
        this.chkcontactado.setEnabled(true);
    }

        public void enviarCedula(String cedula) throws SQLException {
   
            Conexion conexion=new Conexion();
            Persona per=conexion.buscarPersona(cedula);
            this.cedulaActual=cedula;
            this.lblusuario.setText(per.getNombres()+" "+per.getApellidos());
            
    }

    private void cargarCombosTipoUsuario() throws SQLException {
        Conexion conexion=new Conexion();
        ArrayList<String> lista=conexion.listarFacultades();
        this.cmbTipoFacultad.removeAllItems();
        this.cmbTipoEscuela.removeAllItems();
        this.cmbTipoFacultad.addItem("Facultad");
        this.cmbTipoEscuela.addItem("Escuela");
        for (int i=0; i<lista.size();i++)
        {
            this.cmbTipoFacultad.addItem(lista.get(i));          
        }

    }

    private void habilitarTipoUsuario() {
       this.cmbTipoUsuario.setEnabled(true);
       this.cmbTipoFacultad.setEnabled(true);
       this.cmbTipoEscuela.setEnabled(true);
       this.cmdAgregarFacultad.setEnabled(true);
       this.cmdQuitarFacultad.setEnabled(true);
       this.tablaElegirFacultad.setEnabled(true);
    }

    private void deshabilitarTipoUsuario() {
       this.cmbTipoUsuario.setEditable(false);
       this.cmbTipoFacultad.setEditable(false);
       this.cmbTipoEscuela.setEditable(false);
       this.cmdAgregarFacultad.setEnabled(false);
       this.cmdQuitarFacultad.setEnabled(false);
       this.tablaElegirFacultad.setEnabled(false);
    }
    
    private int comprobarCampos() {
        
        if(!this.txtclave.getText().equals(""))
        {
        if(!this.txtcedula.getText().equals(""))
        {
            if(!this.txtnombres.getText().equals(""))
            {
                if(!this.txtapellidos.getText().equals(""))
                {
                    if(!this.txtdireccion.getText().equals(""))
                    {
                        if(this.cmbciudad.getSelectedIndex()!=0)
                        {
                            if(this.tablaCorreos.getRowCount()!=0)
                            {
                                if(this.tablaTelefonos.getRowCount()!=0)
                                {
                                    if(!this.txtTelefonoPrincipal.getText().equals(""))
                                    {
                                        if(!this.txtCorreoPrincipal.getText().equals(""))
                                         {
                                             if(this.cmbMetodoContacto.getSelectedIndex()!=0)
                                             {  
                                                 if(this.cmbExContactado.getSelectedIndex()!=0)
                                                     return 0;
                                                 else
                                                     JOptionPane.showMessageDialog(this, "No selecciono el estado del alumno.");
                                             }
                                            else
                                                  JOptionPane.showMessageDialog(this, "No selecciono el metodo de contacto.");
                                         }
                                         else
                                             JOptionPane.showMessageDialog(this, "No eligio un correo principal.");
                                   }
                                         else
                                             JOptionPane.showMessageDialog(this, "No eligio un telefono principal.");
                            }
                                else
                                     JOptionPane.showMessageDialog(this, "No hay telefonos agregados.");
                           }
                             else
                                   JOptionPane.showMessageDialog(this, "No hay correos agregados.");
                        }
                           else
                                JOptionPane.showMessageDialog(this, "No eligio una ciudad.");
                  }
                    else
                         JOptionPane.showMessageDialog(this, "No ingreso una direccion.");                            
                   }
                    else
                         JOptionPane.showMessageDialog(this, "No ingreso un apellido.");    
                }
                    else
                         JOptionPane.showMessageDialog(this, "No ingreso un nombre.");   
            }
                    else
                         JOptionPane.showMessageDialog(this, "No ingreso una cedula."); 
         }
                    else
                         JOptionPane.showMessageDialog(this, "No ingreso una clave."); 
        
                                                         
         return 1;                       
    }
}
